package vashion.azeroth.api.controller.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import vashion.azeroth.contant.AzerothConstants;
import vashion.azeroth.core.manager.personal.config.ConfigExchangeRateManager;
import vashion.azeroth.core.personal.pojo.ConfigExchangeRate;


public class UpdateExchangeRateController {
	private final static Logger logger = LoggerFactory.getLogger(UpdateExchangeRateController.class);
	
	private Boolean isOpen;
	
	@Autowired
	private ConfigExchangeRateManager exchangeRateManager;

	public void updateExchangeRate() {
		if(isOpen) {
			logger.info("同步汇率任务开始");
			ConfigExchangeRate exchangeRate = new ConfigExchangeRate();
			exchangeRate.setState(AzerothConstants.ConfigExchangeRate.ConfigExchangeRateState.enable);
			exchangeRateManager.updateExchangeRate(exchangeRate);
			logger.info("同步汇率任务结束");
		}

	}
	
	public Boolean getIsOpen() {
		return isOpen;
	}

	public void setIsOpen(Boolean isOpen) {
		this.isOpen = isOpen;
	}

}
